home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / Amiga_Mail_Vol2 / Archives / Plain / so91.lha / Pattern / SetStar.c < prev   
Encoding:
C/C++ Source or Header  |  1991-10-23  |  2.5 KB  |  98 lines

  1. /*
  2.  * SetStar.c.   AmigaMail '*' wildcard example. Pure code if pragmas are used.
  3.  * Thursday 12-Jul-91 09:33:01, Ewout
  4.  *
  5.  * Compiled with SAS/C 5.10a: lc -cfis -v -d0 -b0 SetStar.c blink from SetStar.o
  6.  * to SetStar \ lib lib:amiga.lib       ; if you don't have pragmas
  7.  *
  8.  */
  9. /* (c)  Copyright 1991 Commodore-Amiga, Inc.   All rights reserved.
  10. The information contained herein is subject to change without notice,
  11. and is provided "as is" without warranty of any kind, either expressed
  12. or implied.  The entire risk as to the use of this information is
  13. assumed by the user.
  14. */
  15.  
  16. #include <exec/types.h>
  17. #include <dos/dosextens.h>
  18. #include <dos/rdargs.h>
  19.  
  20. #include <clib/exec_protos.h>
  21. #include <clib/dos_protos.h>
  22.  
  23. /*
  24.  * undef PRAGMAS if you don't have them #define PRAGMAS
  25.  */
  26. #ifdef PRAGMAS
  27. #include <pragmas/exec_pragmas.h>
  28. #include <pragmas/dos_pragmas.h>
  29. #else
  30. struct ExecBase *SysBase;
  31. struct DosLibrary *DOSBase;
  32.  
  33. #endif
  34.  
  35. static UBYTE   *VersTag = "\0$VER: SetStar 37.1 (12.07.91)";
  36.  
  37.  
  38. VOID            main(VOID);
  39. UWORD           StrLen(UBYTE *);
  40.  
  41. VOID
  42. main(VOID)
  43. {
  44. #ifdef PRAGMAS
  45.     struct DosLibrary *DOSBase;
  46.  
  47. #endif
  48.  
  49.     struct RDArgs  *readargs;
  50.     LONG            rargs[2];
  51.     UWORD           on, off;
  52.  
  53. #ifndef PRAGMAS
  54.     /* set up SysBase */
  55.     SysBase = (*((struct Library **) 4));
  56. #endif
  57.  
  58.     /* Fail silently if < 37 */
  59.     if (DOSBase = (struct DosLibrary *) OpenLibrary("dos.library", 37))
  60.     {
  61.         rargs[0] = 0;
  62.         rargs[1] = 0;
  63.  
  64.         /* See the DOS Autodocs for more information about ReadArgs() */
  65.         if (readargs = ReadArgs("ON/S,OFF/S", rargs, NULL))
  66.         {
  67.             on = (UWORD) (rargs[0]);
  68.             off = (UWORD) (rargs[1]);
  69.  
  70.             /*
  71.              * The RNF_WILDSTAR bit in the rn_Flags field indicates whether the
  72.              * '*' should be treated as wildcard or not.
  73.              *
  74.              * Show current setting if both ON & OFF or specified or neither.
  75.              */
  76.             if (on == off)
  77.             {
  78.                 if (DOSBase->dl_Root->rn_Flags & RNF_WILDSTAR)
  79.                     rargs[0] = (LONG) "ON";
  80.                 else
  81.                     rargs[0] = (LONG) "OFF";
  82.                 VFPrintf(Output(), "Wildstar is %s\n", rargs);
  83.             }
  84.             else
  85.             {
  86.                 if (on)
  87.                     DOSBase->dl_Root->rn_Flags |= RNF_WILDSTAR;
  88.                 else
  89.                     DOSBase->dl_Root->rn_Flags &= ~RNF_WILDSTAR;
  90.             }
  91.             FreeArgs(readargs);
  92.         }
  93.         else
  94.             PrintFault(IoErr(), NULL);
  95.         CloseLibrary((struct Library *) DOSBase);
  96.     }
  97. }
  98.